****************************************************************************************
* Title: Table with proportion of studies with risk populations eligible for enrolment
* Manuscript Ref : Extended data - Table 1 of the manuscript
* Version: 14.2
* Required packages: table1_mc
****************************************************************************************

version 14.2

*Change to folder where the dataset is stored
cd "filepath"
use 2020-05-07_iddo_lsr_covid-19_sr.dta, clear

*Change to folder where you want results saved
cd "filepath"


*Only keep one record per study for a study-level database
keep if pickone_study_level_record==1

*Generate children (under age 18) eligible for inclusion variable using pa_elig_age_min
gen pa_elig_under18 = pa_elig_age_min<18
replace pa_elig_under18 = 99 if pa_elig_age_min==.
label variable pa_elig_under18 "Children (under 18 years)"
label define pa_elig_under18_lbl 0 "No" 1 "Yes" 99 "Unknown"
label values pa_elig_under18 pa_elig_under18_lbl

*Label risk populations
label variable pa_elig_preg_yn "Pregnant women"
label variable pa_elig_diab_yn "Patients with diabetes mellitus"
label variable pa_elig_hiv_yn "Patients with HIV"
label variable pa_elig_immu_yn "Immunocompromised paricipants (including cancer treatment)"
label variable pa_elig_asthma_yn "Patients with chronic lung disease or moderate to severe asthma"
label variable pa_elig_ht_yn "Hypertensive patients"
label variable pa_elig_heart_yn "Patients with serious heart conditions"
label variable pa_elig_obese_yn "Severely obese participants (body mass index >40)"

*Prepare descriptive table of patient eligibility by 
table1_mc, clear format(%2.0f) percformat(%12.2g) onecol nospacelowpercent slashN iqrmiddle(", ") ///
vars(pa_elig_preg_yn cat ///
\ pa_elig_under18 cat ///
\ pa_elig_diab_yn cat ///
\ pa_elig_hiv_yn cat ///
\ pa_elig_immu_yn cat ///
\ pa_elig_asthma_yn cat ///
\ pa_elig_ht_yn cat ///
\ pa_elig_heart_yn cat ///
\ pa_elig_obese_yn cat ///
)

*Export table to .xls
export excel factor Total using "Extended_data_table1.xls", replace
